Methods and apparatus for processing variable length coded data

ABSTRACT

An apparatus for processing variable length coded data includes a coefficient buffer unit and several lookup tables. The coefficient buffer unit includes a coefficient memory and an index register for storing an indication of a non-zero nature of coefficients stored in the coefficient memory. Advantageously, the lookup tables may be altered to adapt the apparatus for processing variable length coded data to handle encoding or decoding video adhering to a specific standard. Furthermore, the lookup tables may be adapted to accelerate the determination of the presence of escape codes and the subsequent handling of the escape codes.

CROSS REFERENCE TO RELATED APPLICATIONS

The present application claims the benefit of prior application Ser. No.60/609,511, filed Sep. 13, 2004.

FIELD OF THE INVENTION

The present invention relates to processing of variable length codeddata and, more particularly, to methods and apparatus for suchprocessing.

BACKGROUND

There has recently been a great deal of interest in supporting a widearray of standards for video encoding and decoding in consumer products.Digital video standards of commercial interest include: theInternational Standards Organization (ISO) MPEG-2 and MPEG-4 standards;the Microsoft® VC-1 draft standard; the International TelecommunicationUnion Telecommunication Standardization Sector (ITU-T) H.263 and H.264standards; the On2 VP6 standard; and the digital videotape (DV)standard.

It is likely that multi-standard video encoders and decoders will becomemore prevalent in coming years in a wide array of products. Suchproducts may include: set-top boxes for receiving video over cable,digital subscriber line (DSL), satellite link and/or the Internet;digital TVs; personal video recorders; handheld devices (includingpersonal digital assistants, dedicated personal video players and mobilephones); and wireless devices. High performance processors will berequired for running applications on these widely varied products.

Fixed function variable length coder/decoder units are available, where“fixed function” refers to the fact that such units are dedicated to aparticular standard, for example, the H.264 standard. Fixed functionvariable length coder/decoder units may also be found in typical MPEG-2video encoder and video decoder chips including the Xilleon™ 200 familyof chips from ATI Technologies Inc. of Markham, Ontario, Canada.Unfortunately, fixed function variable length coder/decoder units lackthe flexibility to work across a variety of video compression methods.

It is also known that variable length coding/decoding may also beperformed by a general purpose reduced instruction set computer (RISC)processor or a complex instruction set computer (CISC) processor, suchas those found in personal computers. However, such high-performancegeneral purpose processors are hard to characterize in terms of worstcase performance, due to the dependence of general purpose processors onthe statistical behavior of instruction and data caches. Additionally,general purpose processors are expensive to implement, as they requirelarge die area. General purpose processors are also relativelyinefficient at handling variable-length data, since they are implicitlydesigned for processing byte-aligned data.

Many of the digital video standards transform eight pixel by eight pixelarrays that are representative of a portion of a frame in a digitalvideo sequence. The result of this transformation may be called a blockof coefficients. The block of coefficients may be encoded using variablelength codes as a form of efficient compression. A macroblock may bedefined to include four eight-by-eight luminance blocks of coefficientsand two eight-by-eight chrominance blocks of coefficients.

The output of a video encoder in some standards is known as anElementary Stream (ES). The lowest-level entity in the ES is a encodedblock of coefficients. Each encoded block is terminated by anend-of-block code. A macroblock may be formed by concatenating the fourluminance blocks and the two chrominance blocks. The six encoded blocksmay be preceded by a macroblock header that contains control informationbelonging to the macroblock: spatial address, motion vectors, predictionmodes, field/frame DCT mode, quantizer step size. The result is a codedmacroblock.

Variable length codes often arise out of attempts to compress an amountof data to be transmitted. One type of variable length code is the“run-level” type of code. Run-level codes recognize situations in whicha sequence of values are to be transmitted, where many of the values arenull (0). The code replaces a long series of null values with anindication of the value (level) that follows the series and anindication of the length (run) of the series. Through the use of such acode, a series of 28 0-valued bits that precede a value of 17 may bereduced to a indication of the 17 (a level value) and five bits (a runvalue) indicating that there is a series of 28 null values ahead of the17.

Compression codes also include so-called entropy encoding schemeswherein the most common symbols are mapped to the shortest code strings.An example of an entropy encoding scheme is Huffman coding, which isused in the MPEG-2 standard. In the MPEG-2 standard, for example, blocksof coefficients are first run-level encoded and then each run-levelcombination (symbol) is Huffman encoded.

Run-level encoding, in particular, requires that a block of coefficientsbe written into locations in a coefficient buffer. A run-level encodermay then read the coefficient buffer, location by location, to determinerun-level combinations representative of the block of coefficients. Inthe reverse, decoding, case, a run-level decoder receives run-levelcombinations and uses the run-level combinations to formulate a block ofcoefficients in a coefficient buffer. As there are typically many nullentries in a block of coefficients, it may be considered that thewriting, by the run-level decoder, of null entries to the coefficientbuffer is inefficient.

Huffman encoding, in particular, requires that a code be determined tocorrespond to each received run-level combination. For the sake ofefficiency, a single code may map to more than one run-levelcombination. For instance, a maximum run value may be defined and agiven run-level combination may include a given run value and a givenlevel value. When the given run value exceeds the maximum run value, themaximum run value may be subtracted from the given run value to providean intermediate run value. The code generated then corresponds to acombination of the intermediate run value and the given level value. Todistinguish this code from the same code generated when the received runvalue is equivalent to the intermediate run value just determined, theformer code may be preceded by an “escape code”. In particular, theescape code may identify the following code to be a “delta-run” code. A“delta-level” code may be similarly determined and identified.

Determining an escape code to generate based on received run and levelvalues can be a complex and processor-time consuming exercise. Existingencoders are known to either implement a hardwired approach, which isinherently inflexible, or implement a programmed approach on ageneral-purpose RISC processor or a purpose-specific processor.Unfortunately, such existing approaches do not specifically acceleratethe determining and handling of escape codes.

Clearly, then, there is a need for methods and apparatus for efficientlyencoding and decoding data that manipulates variable length coded dataefficiently at very high processing rates.

SUMMARY

An apparatus for processing variable length coded data includes acoefficient buffer unit and several lookup tables. The lookup tables, inparticular, may be adapted to accelerate the determination of thepresence of escape codes and the subsequent handling of the escapecodes. For instance, a lookup table may select, based on results of anumber of comparisons, a type of escape code from among a plurality oftypes of escape code. Alternatively, a lookup table may select, based onsome received values and some values located in the lookup table, a typeof escape code from among a plurality of types of escape code. Further,an escape code may be identified by correlating an initial bit patternin a received code to known bit patterns related to escape codes.

Additionally, the coefficient buffer unit may include a memory and anindex register for storing an indication of a non-zero nature ofcoefficients stored in the memory. Advantageously, the index registerallows for more efficient processing of blocks of coefficients duringboth encoding and decoding. Furthermore, the lookup tables may bealtered to adapt the apparatus for processing variable length coded datato handle encoding or decoding video adhering to a specific standard.

According to an aspect of the present invention, there is provided amethod of populating a memory for use in decoding a stream of encodedvalues. The method includes initializing, to an initial value, a pointerto a memory location in the memory, receiving a run value and anassociated level value in the stream, updating the pointer using the runvalue, to give an updated pointer, populating a memory location in thememory, the memory location in the memory identified by the updatedpointer, using the level value and populating a memory location in anindex register, the memory location in the index register identified bythe updated pointer, to indicate that the memory location in the memoryidentified by the updated pointer has been populated. In another aspectof the invention, a run-level decoding apparatus is provided forcarrying out this method.

According to another aspect of the present invention, there is provideda method of handling coefficient data received from a first memory. Themethod includes receiving a coefficient value stored in the first memoryat a given address, receiving an index register value stored in an indexregister at an address corresponding to the given address anddetermining, based on the index register value, whether to write thecoefficient value to a second memory. In another aspect of theinvention, a direct memory access apparatus is provided for carrying outthis method.

According to still another aspect of the present invention, there isprovided a method of run-level encoding. The method includesinitializing a value of a first pointer to a first memory location in amemory that includes a plurality of memory locations, receiving acoefficient vector having a plurality of indexed coefficient vectorelements corresponding to the plurality of memory locations,incrementing a value of a second pointer to a location in thecoefficient vector until the second pointer references a location of agiven indexed coefficient vector element that indicates a presence of acoefficient in a second memory location in the memory, where the secondmemory location corresponds to the given indexed coefficient vectorelement, determining a difference between the value of the first pointerand the value of the second pointer, determining a run value based onthe difference, outputting the run value, reading, from the secondmemory location, a coefficient value and outputting the coefficientvalue as a level value. In another aspect of the invention, a run-levelencoding apparatus is provided to carry out this method.

According to a further aspect of the present invention, there isprovided a programmable apparatus for processing variable length codeddata. The programmable apparatus includes a memory having a plurality ofmemory locations, a register storing a pointer to a particular memorylocation of the plurality of memory locations, a lookup table storing areference to the pointer associated, at least in part, with a run valueand a level value and a processor. The processor is adapted to execute asequence of instructions stored in the memory and responsive toreceiving the reference to the register, branch the executing away fromthe sequence to execute an instruction stored in the particular memorylocation.

According to a still further aspect of the present invention, there isprovided an escape code selection apparatus for producing variablelength coded data. The escape code selection apparatus includes a firstcomparator adapted to compare a received run value to a previouslystored run value to produce a first comparison result, a secondcomparator adapted to compare a received level value to a previouslystored level value to produce a second comparison result and a logicunit adapted to select, based, at least in part, on the first comparisonresult and the second comparison result, a type of escape code fromamong a plurality of types of escape code.

According to an even further aspect of the present invention, there isprovided a method of producing variable length coded data. The methodincludes receiving a run value represented as a run plurality of bits,receiving a level value represented as a level plurality of bits,forming an address by combining the run value and the level value, usingthe address to determine a value for a disambiguation bit, determining amaximum level value for the run value, determining a maximum run valuefor the level value and selecting, based, at least in part, on the runvalue, the level value, the maximum run value, the maximum level value,the disambiguation bit and previously stored values, a type of escapecode from among a plurality of types of escape code. In another aspectof the invention, an escape code selection apparatus is provided forcarrying out this method.

According to an even further aspect of the present invention, there isprovided a method of handling variable length coded data. The methodincludes receiving a string of binary digits, receiving a prefix firstportion length, comparing a first number of binary digits of the stringto a reference string, where the first number is equivalent to theprefix first portion length, based on the comparing, generating apositive match indicator and generating an output string having apredetermined prefix second portion length, where the output stringincludes values of a second number of binary digits in the string ofbinary digits that directly follow the first number of binary digits,where the second number is equivalent to the prefix second portionlength. In another aspect of the invention, an escape code correlator isprovided for carrying out this method.

Other aspects and features of the present invention will become apparentto those of ordinary skill in the art upon review of the followingdescription of specific embodiments of the invention in conjunction withthe accompanying figures.

BRIEF DESCRIPTION OF THE DRAWINGS

In the figures which illustrate example embodiments of this invention:

FIG. 1 illustrates a video CODEC circuit employing a programmablemicrocoded engine according to an embodiment of the present invention;

FIG. 2 illustrates the microcoded engine of FIG. 1 including acoefficient buffer unit and various lookup table units according to anembodiment of the present invention;

FIG. 3 illustrates the coefficient buffer unit of the programmablemicrocoded engine of FIG. 2 in encode mode according to an embodiment ofthe present invention;

FIG. 4 illustrates an index lookup table unit of the programmablemicrocoded engine of FIG. 2 in encode mode according to an embodiment ofthe present invention;

FIG. 5 illustrates a table for use in converting level and run values tovariable length codes;

FIG. 6 illustrates a general purpose lookup table unit of theprogrammable microcoded engine of FIG. 2 in encode mode according to anembodiment of the present invention;

FIG. 7 illustrates a value lookup table unit of the programmablemicrocoded engine of FIG. 2 in encode mode according to an embodiment ofthe present invention;

FIG. 8 illustrates, as a detailed block diagram, an engine interface andbitstream buffer unit of the programmable microcoded engine of FIG. 2;

FIG. 9 illustrates arrays of memory locations for the scan table and acoefficient memory for the coefficient buffer unit of FIG. 3;

FIG. 10 illustrates steps in a method of controlling the generation ofrun/level/last data at the coefficient buffer unit of FIG. 3;

FIG. 11 illustrates the index lookup table unit of FIG. 4 in decode modeaccording to an embodiment of the present invention;

FIG. 12 illustrates an escape code correlator of index lookup table unitof FIG. 11 according to an embodiment of the present invention;

FIG. 13 illustrates the value lookup table unit of FIG. 7 in decode modeaccording to an embodiment of the present invention;

FIG. 14 illustrates the coefficient buffer unit of FIG. 3 in decode modeaccording to an embodiment of the present invention;

FIG. 15 illustrates steps in a method of controlling the generation ofcoefficients from run/level/last data at the coefficient buffer unit ofFIG. 14; and

FIG. 16 illustrates steps in a method of decoding received run and levelvalues to determine coefficient values according to an embodiment of thepresent invention

DETAILED DESCRIPTION

FIG. 1 illustrates a video CODEC (COder-DECoder) circuit 100 for use inencoding and decoding a digital video sequence. A digital video sequencemay be considered a series of digital still images, where each digitalstill image is described by values of picture elements, called “pixels”.A discrete cosine transform (DCT) unit 102 may be used to represent thedigital still images as arrays of quantized coefficients. The DCT unit102 may also implement motion compensation techniques, and othertechniques, to reduce the total number of arrays of quantizedcoefficients and to reduce the number of non-zero coefficients per arrayof quantized coefficients. The arrays may then be stored in a sharedmemory 104, where the arrays may be accessed by a programmablemicrocoded engine 106 for processing variable length coded data. Themicrocoded engine 106 may use the arrays to generate variable lengthcoded data representative of the arrays of coefficients. The variablelength coded data may then be output to a stream buffer 108 undercontrol of a video processing controller 110. The video processingcontroller 110 may also insert additional syntax elements (both fixedand variable length) among the variable length coded data produced bythe microcoded engine 106.

FIG. 2 illustrates, as a block diagram, the programmable microcodedengine 106. Microcode refers to low level instructions that control amicroprocessor. The microcode of the microcoded engine 106 may bereprogrammed to allow the microcoded engine 106 to be adapted for use inmultiple video encoding and decoding applications, i.e., encoding anddecoding according to a selected standard among multiple standards.

The microcoded engine 106 includes a processor 220 for executing asequence of instructions stored in an instruction memory 222. Theinstruction memory 222 has a plurality of instruction memory locations.Associated with the processor 220 is a plurality of registers, whereeach register is for storing a pointer to a particular instructionmemory location in the instruction memory 222.

The microcoded engine 106 includes a local register data transfer bus202 that includes an address bus and a data bus and is controlled by asequencer and bus controller 204 within the processor 220. An array ofspecial processing units are connected for communication through thelocal register data transfer bus 202.

The special processing units may include a bitstream buffer (BSB) unit206 for providing read access to bitstreams stored in the stream buffer108 that include variable length binary strings. Equally, the BSB unit206 may write bitstreams to the stream buffer 108, where the bitstreamsinclude variable length binary strings. The BSB unit 206 may communicatewith the local register data transfer bus 202, and thereby with the restof the special processing units, via an engine interface 207.

The special processing units may also include a Co-Efficient Buffer(CEB) unit 208. As will be described, the CEB unit 208 may be arrangedto perform scan conversion on-the-fly from a random access memory (RAM)based scan table. The CEB unit 208 may also, when encoding, handlecreation of a zero/non-zero flag vector as part of a direct memoryaccess (DMA) operation, which transfers coefficients from the sharedmemory 104. The CEB unit 208 may also, when decoding, force coefficientsto zero as part of the DMA operation that transfers coefficients to theshared memory 104, based on the zero/non-zero flag vector. The CEB unit208 may also transpose columns of coefficients to allow for efficientburst access.

The special processing units may also include a Value Lookup Table(VLUT) unit 212 adapted to convert a received code index to acorresponding variable length code string and a representation of thelength of the variable length code string, when encoding, or to converta received code index to non-zero value (level) and an indication ofseparation from a prior non-zero value (run), when decoding. The outputof the VLUT unit 212 may be processed through a set of programmablebarrel shifters in an arithmetic logic unit (ALU) 218, whichprogrammable barrel shifters allow single cycle shifting and rotating ofdata words. Such processing may be seen to allow for efficient alignmentof the various output bit fields in different modes.

The special processing units may also include an Index Lookup Table(ILUT) unit 214 adapted to, in a decode mode, find the codebook index ofa variable length code applied to the ILUT unit 214 and, in an encodemode, find a variable length code index corresponding to receivedcodebook symbol information applied to the ILUT unit 214, dependent uponthe setting of a mode bit. The ILUT unit 214 may be RAM-based or ContentAddressable Memory-based.

The special processing units may also include a General Purpose LookupTable (GLUT) unit 216. The GLUT unit 216 may be particularly useful fordetermining when level and run values exceed limits in a table that mapssuch level and run values to variable length codes.

As mentioned in passing above, the special processing units may includeconventional elements, such as the ALU 218. As with known ALUs, the ALU218 employs a collection of logic gates to perform operations such asaddition, subtraction, and multiplication of integers as well asbit-wise Boolean operations (e.g., AND, OR, NOT, XOR).

In FIG. 2, the local register data transfer bus 202 is shown abstractly.In practice, the address bus and data bus that make up the localregister data transfer bus 202 can be implemented through tri-statecontrolled buses or through the use of multiplexing logic to selectamong data sources, the latter being more commonly used in modemintegrated circuits. Furthermore the portion of the data bus thatcarries data written by the sequencer and bus controller 204 may bedistinct from the portion of the data bus employed to carry data readfrom the various special processing units 208, 212, 214, 216, 218.

The CEB unit 208, illustrated in detail in FIG. 3, includes a DMA unit302 for reading DCT coefficients from the shared memory 104 in encodemode and writing DCT coefficients to the shared memory 104 in decodemode. In communication with the DMA unit 302 is a scan table unit 304for converting, according to a selected scan table, a memory locationspecified by the DMA unit 302 to a memory location in a coefficientmemory 306. Dependent upon encode or decode mode, the coefficient memory306 may be read from, or written to, by a run-level unit 308. Access tothe coefficient memory 306 may be mirrored by access to an indexregister unit 310 that is arranged to maintain, in an associated indexregister, a record of the presence or absence of a coefficient at eachmemory location in the coefficient memory 306.

The ILUT unit 214, illustrated in detail in FIG. 4, includes severallookup tables. For use in encode mode, the lookup tables include a runand level to index lookup table 402, a disambiguation bit lookup tableunit 404, a run maxima lookup table 602 and a level maxima lookup table604. To select between a received level value and an adjusted levelvalue for use in the run and level to index lookup table 402, a levelmultiplexer (MUX) 410 is provided. For use in decode mode, the ILUT unit214 includes a variable length code to index lookup table 412 and anescape code correlator 414.

The GLUT unit 216, as illustrated in detail in FIG. 6, includes a runmaxima look up table 602, which receives, as input, the level value andthe last indication generated at the CEB unit 208 as well as a levelbase address and generates, as output, a maximum run value for theprovided level value. Similarly, the GLUT unit 216 includes a levelmaxima look up table 604, which receives, as input, the run value andthe last indication generated at the CEB unit 208 as well as a run baseaddress and generates, as output, a maximum level value for the providedrun value.

The output of the run maxima look up table 602 is received by a runmultiplier 606R while the output of the level maxima look up table 604is received by a level multiplier 606L. The output of the run multiplier606R is received by a first comparator 607A, which also receives the runvalue received from the CEB unit 208. The output of the level multiplier606L is received by a second comparator 607B, which also receives thelevel value received from the CEB unit 208. The output of the run maximalook up table 602 is also received by a third comparator 607C, whichalso receives the run value received from the CEB unit 208. Similarly,the output of the level maxima look up table 604 is received by a fourthcomparator 607D, which also receives the level value received from theCEB unit 208. A fifth comparator 607E receives the maximum level valuefrom the ILUT unit 214 and the level value received from the CEB unit208.

The output of the five comparators 607A, 607B, 607C, 607D, 607E may bereceived by a compare logic unit 608, whose output may be a jump indexfor the processor 220 and/or an adjusted level value for the ILUT unit214. A jump index may be an indication of a particular register amongthe registers 224, where the particular register stores a pointer to aninstruction in the instruction memory 222 that may be executed by theprocessor 220.

As illustrated in FIG. 7, the VLUT unit 212 includes a value lookuptable 702 for determining a variable length code based on a receivedindex value. Alternatively, when loaded with different data, the valuelookup table 702 included in the VLUT unit 212 can be used to provide arun and level lookup that may be used to determine a run value, levelvalue and last indication based on a received index value.

An exemplary configuration for the engine interface 207 and the BSB unit206 is illustrated in FIG. 8. An address decoder 810 within the engineinterface 207 is connected to an address bus 802 and a data bus 803,which are part of the local register data transfer bus 202, forcommunication with the sequencer and bus controller 204 at the processor220.

The address decoder 810 connects to a read_bits register 812, aread_data register 814, a write_bits register 816 and a write_dataregister 818, also of the engine interface 207. The four registers 812,814, 816, 818 represent “memory mapped” ports. Storage elements, such asflip-flops, may or may not be associated with the registers 812, 814,816, 818. Each of the registers 812, 814, 816, 818 connects both to thedata bus 803 and to a variable length string interface 820. The variablelength string interface 820 receives input from a read FIFO 822 andprovides output to a write FIFO 824.

A drawing similar to FIG. 8 may be constructed, wherein the engineinterface 207 is register mapped such that access to the BSB Unit 206 isdetermined by encoded instruction fields, rather than memory busaddresses.

In overview, the microcoded engine 106, with the array of specialprocessing units connected via one or more register data transfer buses,may be employed to convert arrays of quantized DCT coefficients tovariable length coded data in encode mode and to convert variable lengthcoded data to arrays of quantized DCT coefficients in decode mode.Important to the operation of the microcoded engine 106 is the CEB unit208 for converting the quantized DCT coefficients to level and runvalues in encode mode and converting level and run values to quantizedDCT coefficients in decode mode. Additionally, several lookup tables212, 214, 216 are employed for conversion between level and run valuesand variable length coded data representative thereof and vice versa.

In operation, the CODEC circuit 100 may be used in encoding a digitalvideo sequence to produce variable length coded data or may be used indecoding variable length codes to produce a digital video sequence. Theencoding operation may be considered first.

When the CEB unit 208 is in an encode mode, blocks of DCT coefficientsare transferred from the shared memory 104 into the coefficient memory306 and then read out as run/level/last values under the control of theprocessor 220. The coefficient memory 306 may be treated as a ping-pongbuffer with each side holding one eight by eight block of coefficients,where a coefficient may be, for instance, represented by a 16-bit value.As is known, a ping-pong buffer contains two separate buffers so that,while data is written to one buffer, data may be read from the otherbuffer.

The transfer of the blocks of DCT coefficients from the shared memory104 into the coefficient memory 306 may be arranged to occur onecoefficient at a time. According to instruction received from theprocessor 220, the DMA unit 302 requests, from the shared memory 104, aspecific coefficient by the memory location (ADDR, see FIG. 3) of thespecific coefficient in the coefficient array as stored in the sharedmemory 104. Once the DMA unit 302 receives the specific coefficient(RDATA), the DMA unit 302 transmits the specific coefficient (WDATA) tothe coefficient memory 306 while specifying the memory location (ADDR)to the scan table unit 304. The scan table unit 304 may use a selectedRAM-based scan table to determine a memory location (WADDR) for thespecific coefficient in the coefficient array as stored in thecoefficient memory 306.

As the coefficient memory 306 receives the specific coefficient (WDATA)and the memory location (WADDR) for storing the specific coefficient,the same information is received by the index register unit 310. At thememory location (WADDR) in an index register within the index registerunit 310, a binary indication of whether the specific coefficient iszero (e.g., binary indication=0) or non-zero (e.g., binary indication=1)may be recorded. Once the entire DCT coefficient array has beentransferred from the shared memory 104 to the coefficient memory 306, a64-bit (in the case of an eight-by-eight DCT coefficient array) codedcoefficient vector may be generated from the bits in the index registerunit 310.

According to some standards, e.g., MPEG-2, a coefficient array may bestored for encoding in a manner different from the manner in which thecoefficient array was stored after creation. As illustrated in FIG. 9, afirst array 902 illustrates memory locations of DCT coefficients (byreference number) in an array as stored after creation. For instance,where memory locations in the array may be referred to in an (x, y)format, where x is a horizontal index (x=0, 1, . . . , 7) and y is avertical index (y=0, 1, . . . , 7), the memory location (2, 0) in thefirst array 902 holds the DCT coefficient with reference number 2.

The scan table unit 304 may be used to re-order the DCT coefficientsinto a “zig-zag” sequence, which is known to help to facilitate entropycoding by placing low-frequency coefficients before high-frequencycoefficients.

The zig-zag sequence reordering is represented by a second array 904 inFIG. 9, in which a given memory location is represented by the referencenumber of the DCT coefficient occupying the given memory location in thefirst array 902. According to the second array 904, when the DMA unit302 specifies memory location (0, 1) for storing the DCT coefficientwith reference number 8, the second array 904 indicates memory location(2, 0) (i.e., the memory location in the first array 902 of DCTcoefficient with reference number 2) for storing the DCT coefficient inthe coefficient memory 306. A third array 906 in FIG. 9 illustrates thememory locations of the DCT coefficients after being written to thecoefficient memory 306 in memory locations selected according to thesecond array 904. Continuing the example above, the DCT coefficient withreference number 8 may be found in the third array 906 in memorylocation (2, 0).

In a second example, according to the second array 904, when the DMAunit 302 specifies memory location (4, 4) for storing the DCTcoefficient with reference number 36, the second array 904 generatesmemory location (7, 4) (i.e., the memory location in the first array 902of DCT coefficient with reference number 39) for storing the DCTcoefficient in the coefficient memory 306.

In this manner, a first block of coefficients may be transferred, by theDMA unit 302, from the shared memory 104 into the coefficient memory306. Subsequently, a second block of coefficients may be transferred, bythe DMA unit 302, from the shared memory 104 into the other side of thecoefficient memory 306 while the first block is processed by the otherspecial processing units of the microcoded engine 106.

The sequence of events for encoding at the CEB unit 208 is illustratedin FIG. 10 to begin with the setting up of some registers in the DMAunit 302 (step 1002). Two identical sets of registers may be set up toallow for separate and independent access to the shared memory 104. TheDMA registers may include: a register for indicating a start address inthe shared memory 104; a register for indicating a start address in thecoefficient memory 306; a register for indicating a selection of a scantable in the scan table unit 304; and a register for indicating a numberof 128-bit (eight-coefficient) words to transfer for each block, e.g.,eight words for an eight pixel by eight pixel block.

Registers may also be set up in the run-level unit 308 (step 1004). Forexample, a register may be set up to indicate a start address in thecoefficient memory 306 for reading by the run-level unit 308.Additionally, a register may be set up such that writing to the registerwill initialize the hardware, i.e., write a zero value to each memorylocation in each memory location in the index register associated withthe index register unit 310.

A register may also be set up to indicate a maximum number ofcoefficients to encode. Under normal circumstances, the value in thisregister is equivalent to the block size (e.g., 64 coefficients), butthis register may be used to limit encoding by defining a maximum numberof coefficients for which to generate variable length codes, regardlessof the number of coefficients actually encoded. This register may beused by the run-level unit 308 to determine when to set the lastindication.

A register may also be used to indicate a DCT block size. Such a DCTblock size register may be used to establish a valid portion of thecoefficient memory 306 during processing.

The processor 220 may trigger the DMA unit 302 (step 1006) to read theshared memory 104, first, by writing an indication to one of the two DMAsetup registers to be used for such a purpose and, second, by writing anindication that the required operation is a DMA Read (get) operation.

The processor 220 may read a DMA status register (step 1008) todetermine when the requested memory access is completed. If the DMAstatus register indicates that the requested memory access is ongoing,the processor 220 may wait before reading the DMA status register again.Once the processor 220 has determined that the requested memory accessis complete, the processor 220 may trigger the ILUT unit 214 (step 1012)to obtain successive run/level/last data for encoding by writing to aregister specifically designed to trigger such obtaining.

While triggering the ILUT unit 214 (step 1012) to obtain successiverun/level/last data for encoding, the processor 220 may determinewhether all the DCT coefficients in the block have been read (step1014), or, at least, whether all the DCT coefficients to be encoded(based on an indication in the register that specifies this quantity)have been read. This determination may be made by monitoring the lastindication output from the run-level unit 308. However, it should benoted that, even as the CEB unit 208 determines that all the DCTcoefficients in one block have been read from one side of thecoefficient memory 306, the next block is being loaded into the otherside of the coefficient memory 306 from the shared memory 104.

Upon determination that all the DCT coefficients in the block have beenread (step 1014), the processor 220 may set up the registers (step 1002)in the DMA unit 302 for reading the next block.

To facilitate generation of run/level/last data, the run-level unit 308may initialize (step 1004) a record of a “read index pointer” (RIP) anda “previous read pointer” (PRP) to refer to memory locations in thecoefficient memory 306 and corresponding memory locations in the CodedCoefficient Vector received from the index register unit 310.

Each time the run-level unit 308 receives an instruction from theprocessor 220 to produce run/level/last data (step 1012), the run-levelunit 308 begins a data processing operation that may be logicallyequivalent to the following sequence of steps:

-   1) Initialize the value of the RIP to point to the first element of    the vector;-   2) Determine whether the value of the Coded Coefficient Vector    element at the location pointed to by the RIP is zero;-   3) If the value of the Coded Coefficient Vector element at the    location pointed to by the RIP is zero then:    -   increment the value of the RIP such that the RIP points to the        next element of the Coded Coefficient Vector; and    -   return to Step 2);-   4) If the value of the Coded Coefficient Vector element at the    location pointed to by the RIP is one then:    -   determine a difference between the value of the RIP and the        value of the PRP;    -   output a value one less than the difference as the run value;        and    -   write the value 0 to the Coded Coefficient Vector element at the        location pointed to by the RIP;-   5) Output the coefficient value stored in the coefficient memory 306    at the memory location corresponding to the location pointed to by    the RIP as the level value.-   6) Update the value of the PRP to be equal to the value of the RIP;-   7) If all of the remaining elements of the Coded Coefficient Vector,    starting at the element pointed to by the RIP, are zero then set the    “last” indication to 1; otherwise set the “last” indication to 0 and    return to Step 2).

Note that it may be advantageous to represent the level value using asign-and-magnitude representation, where the “level” is actually themagnitude of the coefficient value. The following discussion generallyassumes that the level represents the coefficient magnitude. Note that,although the above procedure is specified sequentially, the equivalentdata processing operation may be carried out in digital logic in asingle processor cycle.

For example, consider the following DCT coefficient array as stored inthe shared memory 104:

$\quad\begin{bmatrix}{- 474} & {- 68} & 102 & 0 & 45 & 70 & {- 57} & 42 \\0 & {- 62} & {- 71} & {- 58} & 0 & {- 33} & 0 & 0 \\0 & 73 & 41 & 64 & 0 & 0 & 0 & 0 \\0 & 0 & {- 42} & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{bmatrix}$After transfer from the shared memory 104 by the DMA unit 302 accordingto the zig-zag pattern provided by the scan table 304, the coefficientsmay be stored in the coefficient memory 306 as follows:

$\begin{bmatrix}{- 474} & {- 68} & 0 & 0 & {- 62} & 102 & 0 & {- 71} \\73 & 0 & 0 & 0 & 41 & {- 58} & 45 & 70 \\0 & 64 & {- 42} & 0 & 0 & 0 & 0 & 0 \\0 & 0 & {- 33} & {- 57} & 42 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{bmatrix}.$While the coefficients are being stored in the coefficient memory 306, acorresponding array is being created in the index register unit 310 asfollows:

$\begin{bmatrix}1 & 1 & 0 & 0 & 1 & 1 & 0 & 1 \\1 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 1 & 1 & 1 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{bmatrix}.$

For purposes of run value and level value determinations, the array inthe coefficient memory 306 may be considered a one-dimensionalcoefficient vector, (−474, −68, 0, 0, −62, 102, 0, −71, 73, 0, 0, 0, 41,−58, 45, 70, 0, 64, −42, 0, 0, 0, 0, 0, 0, 0, −33, −57, 42, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0). Additionally, the corresponding array in the index register unit 310may be considered a coded coefficient vector, (1, 1, 0, 0, 1, 1, 0, 1,1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0). The coded coefficient vector may be transferred from the indexregister unit 310 to the run-level unit 308 for the generation of runand level values.

Upon receiving a command from the processor 220 to produce a run valueand a level value, the run-level unit 308 may sequentially read bitsfrom the coded coefficient vector and increment the read index positionuntil a bit is read that indicates the presence of a coefficient in thecoefficient memory 306. The run-level unit 308 may then determine adifference between a previous read position and the read index positionand output the difference as the run value. The run-level unit 308 maythen read a coefficient value from a memory location in the coefficientmemory 306 corresponding to the read index position in the codedcoefficient vector and output the coefficient value as the level value.

Continuing the example, the following run and level values would begenerated by the run-level unit 308:

-   run=0, level=−474-   run=0, level=−68-   run=2, level=−62-   run=0, level=102-   run=1, level=−71-   run=0, level=73-   run=3, level=41-   run=0, level=−58-   run=0, level=45-   run=0, level=70-   run=1, level=64-   run=0, level=−42-   run=7, level=−33-   run=0, level=−57-   run=0, level=42

When the “last” indication has been set to 1 (see Step 7 above) therun-level unit 308 may output the last indication indicating that theremainder of coefficients for the current block of DCT coefficients arezero.

Turning to FIG. 4 and the operation of the ILUT unit 214, upon receiptof the run/level/last data, the ILUT unit 214 uses the disambiguationbit lookup table unit 404, with the run/level/last data as input, togenerate a single disambiguation bit for transmission to the GLUT unit216. According to criteria to be discussed below, the GLUT unit 216 maygenerate an adjusted level value. The adjusted level value may bereceived by the level MUX 410 along with the level value received by theILUT unit 214. The ILUT unit 214 uses the received run value and theoutput of the level MUX 410 to reference the run and level lookup table402 to generate an index for transmission to the VLUT unit 212.

The index generated by the ILUT unit 214 may be used by the VLUT unit212 to find a Huffman code (or other prefix-free code) valuecorresponding to the symbol defined by the run and level values. Huffmancoding uses a specific method for choosing a code value to representeach run and level combination, resulting in a prefix-free code (thatis, no bit string of any code value is a prefix of the bit string of anyother code value) that expresses the most common run and levelcombinations in the shortest way possible.

Codes that may be derived from run and level combinations aregraphically represented in a table 500 in FIG. 5 to include an“in-table” region 502 and a “not-in-table” region 504. Within thein-table region 502, the code values that may be generated by the valuelookup table 702 are called explicit codes and are specificallyrepresented by the codes in a main region 506. The code values that falloutside the main region 506 are called escape codes and may berepresented in a variety of ways.

A delta-run escape code is a code value outside of the main region 506but inside a delta-run escape region 510. For a given run value andlevel value, a maximum run value supported for the given level value maybe found. When the given run value exceeds the maximum run value, themaximum run value may be subtracted from the given run value to providean intermediate run value. When a delta-run escape code is required, theILUT unit 214 uses the run and level to index lookup table 402 togenerate an index from the intermediate run value and the given levelvalue. The index, so generated, references a code value that may befound in the main region 506.

A delta-level escape code is a code value outside of the main region 506but inside a delta-level escape region. The delta-level escape region isdivided into a delta-level escape (in-table) region 512 and adelta-level escape (not-in-table) region 514. For a given run value andlevel value, a maximum level value supported for the given run value maybe found. When the given level value exceeds the maximum level value yetis still in the delta-level escape (in-table) region 512, the maximumlevel value may be implicitly subtracted from the given level value byappropriate loading of the run and level to index lookup table 402. Whena delta-level escape code is required, the ILUT unit 214 uses the runand level to index lookup table 402 to generate an index from the givenrun value and the level value. The index, so generated, references acode value that may normally be found in the main region 506.

However, when the given level value exceeds the maximum level value andis in the delta-level escape (not-in-table) region 514, it is notpossible to achieve the implicit subtraction of the maximum level valuethrough the use of the run and level to index lookup table. As such, theILUT unit 214 does not generate an index from the given run value andthe intermediate level value. Instead, based on the information providedby the CEB unit 208 and the ILUT unit 214, the GLUT unit 216 generatesan adjusted level value.

In particular, the fourth comparator 607D may compare the level valuereceived from the CEB unit 208 to the maximum level supplied by thelevel maxima lookup table 604. Additionally, the second comparator 607Bmay compare the level value received from the CEB unit 208 to a doublemaximum level value supplied by the level multiplier 606L, where thedouble maximum level value is twice the maximum level supplied to thelevel multiplier 606L by the level maxima lookup table 604.

If the fourth comparator 607D indicates to the compare logic unit 608that the level value received from the CEB unit 208 exceeds the maximumlevel and the second comparator 607B indicates to the compare logic unit608 that the double maximum level value exceeds the received level valueand the fifth comparator 607E indicates to the compare logic unit 608that the received level exceeds the value MAXLEVEL, then the comparelogic unit 608 may ascertain that an adjusted delta-level escape code isnecessary. The compare logic unit 608 may then determine the adjustedlevel by subtracting the maximum level supplied by the level maximalookup table 604 from the level value received from the CEB unit 208.The adjusted level value may then be then transmitted to the ILUT unit214, where the adjusted level value may be received at the level MUX410. The processor 220, having received a jump index from the GLUT unit216 indicating an adjusted delta-level escape code as the escape codetype, may arrange for the level MUX 410 to pass the adjusted level valueto the run and level to index lookup table 402. When an adjusteddelta-level escape code is required, the ILUT unit 214 uses the run andlevel to index lookup table 402 to generate an index from the given runvalue and the adjusted level value. The index, so generated, referencesa code value that may be found in the main region 506.

As the determination of a delta-run escape code or a delta-level escapecode requires determination of a maximum run value for a given levelvalue or a maximum level value for a given run value, the run maximalookup table 602 and the level maxima lookup table 604 may be configuredto provide these values to the run and level to index lookup table 402.

Among the possible run and level combinations are a set of ambiguouscombinations that could lead to either a delta-run escape code or adelta-level escape code. As such, a set of rules is used at the ILUTunit 214 to determine which type of escape code to use. According tothis set of rules, the disambiguation bit lookup table unit 404 may beconfigured to generate, for run and level combinations in the set ofambiguous combinations, a one-bit value that indicates whether thedelta-run escape code or the delta-level escape code is to be used.

The disambiguation bit lookup table unit 404 may receive the run value,the level value and the last indication, where both the run value andlevel value are represented as a number of bits. The disambiguation bitlookup table unit 404 may then form an address by combining the runvalue and the level value in such a manner that the address isrepresented as a value having a fewer number of bits than a sum of thenumber of bits in the run value and the number of bits in the levelvalue. The disambiguation bit lookup table unit 404 may then use theaddress to reference a disambiguation bit lookup table to determine avalue for the disambiguation bit that is transmitted to the GLUT unit216.

The level value received by the ILUT unit 214 may be used as input,along with a run base address, to the run maxima lookup table 602, whichmay output a maximum run value for the received level value fortransmission to the run and level to index lookup table 402.Additionally, the run value received by the ILUT unit 214 may be used asinput, along with a level base address, to the level maxima lookup table604, which may output a maximum level value for the received run valuefor transmission to the run and level to index lookup table 402.

The run base address and the level base address may be used to providean offset from a programming register that remains static during periodsof operation. A base address may be used to allow multiple tables toexist within the run maxima lookup table 602 or the level maxima lookuptable 604. In operation, one of the multiple tables may be selectedthrough the setting of a base address rather than loading a new tableeach time a change is required. As should be clear, setting a singlevalue may be considered much faster than loading an entire table.

A full escape code is a code value that includes an indication of therun value and the level value. Full escape codes may be related to runand level combinations that reference code that are in the full escape(in-table) region 508 or in the full escape (not-in-table) region 516.

In operation, the GLUT unit 216 receives run/level/last data from theCEB unit 208 as well as the disambiguation bit from the ILUT unit 214,when necessary. The GLUT unit 216 may also receive static indications ofa MAXRUN value and a MAXLEVEL value, which define the in-table region502 of the table 500 of FIG. 5. Notably, since all possible run valuesare in the exemplary in-table region 502 of the table 500 of FIG. 5, thereceived MAXRUN value is not used by the exemplary GLUT unit 216 of FIG.6.

The GLUT unit 216 uses the received information to generate anindication of the type of code that will be generated by the VLUT unit212. The indication of type of code, i.e., whether the code is anexplicit code, a delta-run escape code, a delta-level escape code, anadjusted delta-level escape code or a full escape code, is transmittedto the processor 220 in the form of a jump index. The subsequent actionsof the processor 220 are determined by the jump index.

For instance, if the type of code is indicated as an explicit code, theindex generated by the ILUT unit 214 is sent to the VLUT unit 212 and avariable length code corresponding to the index is found in the valuelookup table 702 (FIG. 7). The processor 220 instructs the VLUT unit 212to send the variable length code to the BSB unit 206 via the engineinterface 207.

If the type of code is indicated as a delta-run escape code, the indexgenerated by the ILUT unit 214 is sent to the VLUT unit 212 and avariable length code corresponding to the index is found in the valuelookup table 702 (FIG. 7). The processor 220 sends a code prefixindicative of the delta-run escape code-type to the BSB unit 206 via theengine interface 207 and then instructs the VLUT unit 212 to send thevariable length code to the BSB unit 206 via the engine interface 207.

If the type of code is indicated as a delta-level escape code or anadjusted delta-level escape code, the index generated by the ILUT unit214 is sent to the VLUT unit 212 and a variable length codecorresponding to the index is found in the value lookup table 702 (FIG.7). The processor 220 sends a code prefix indicative of the delta-levelescape code-type to the BSB unit 206 via the engine interface 207 andthen instructs the VLUT unit 212 to send the variable length code to theBSB unit 206 via the engine interface 207.

If the type of code is indicated as a full escape code, the VLUT unit212 is not used and the index output from the ILUT unit 214 may beignored. The processor 220 sends a code prefix indicative of the fullescape code-type to the BSB unit 206 via the engine interface 207 andthen sends the run value and level value to the BSB unit 206 via theengine interface 207.

This sequence of events may be repeated until a block is complete.

Notably, different tables may be loaded into the VLUT unit 212 (thevalue lookup table 702), the ILUT unit 214 (the run and level to indexlookup table 402, the disambiguation bit lookup table unit 404) and theGLUT unit 216 (the run maxima lookup table 602, the level maxima lookuptable 604, the general purpose lookup table 606) to support differentcompression methods and, consequently, different video encoding anddecoding standards.

Reading or writing to the registers 812, 814, 816, 818 of the BSB unit206 of FIG. 8 causes the BSB unit 206 to perform certain actions. Whendata is to be written to the write FIFO 824, the data value isdetermined by a value currently and/or previously written to thewrite_data register 818 and the number of bits which are to be writtenis controlled by values currently and/or previously written to thewrite_bits register 816. In one embodiment of the present invention, theact of writing a value of N to the write_bits register 816 causes therightmost N bits previously written to the write_data register 816 to beappended to a data stream transmitted by the write FIFO 824 to thestream buffer 108.

The variable length string interface 820 combines multiple strings ofbits of varying lengths into data units, each data unit having apredetermined length, for example, an integer multiple of one byte(eight bits) for convenient storage and transmission.

In exemplary operation of the present invention, to write 37 bits to thestream buffer, an element of the microcoded engine 106 writes the 37bits to the write_data register 816. The element then writes the value37 to the write_bits register 816. The act of writing the value 37 tothe write_bits register 816 causes the variable length string interface820 to append the 37 bits written to the write_data register 816 to adata stream transmitted to the write FIFO 824 for transmission to thestream buffer 108.

In operation, the CODEC circuit 100 may be used in encoding a digitalvideo sequence to produce variable length coded data or may be used indecoding variable length codes to produce a digital video sequence. Thedecoding operation may be considered as follows.

The variable length string interface 820 extracts strings of bits ofvarying lengths, at arbitrary starting bit positions, from data unitsreceived at the read FIFO 822. The data units may be arranged to have apredetermined length, for example, an integer multiple of one byte.

When an element of the microcoded engine 106 performs a read on theread_data register 814, the value returned is the value of the next Nbits in the stream buffer 108 connected to the read FIFO 822, relativeto the “current read bit position” in the stream buffer 108. The currentread bit position is controlled by values written to the read_bitsregister 812. When the current read bit position is to be updated, thecurrent read bit position advances according to a value currently orpreviously written to the read_bits register 812.

In exemplary operation of the present invention, the stream buffer 108presents the sequence of bits within the bitstream being processed,starting from the “current read bit position”, at the read_data register814. This sequence of bits can be fetched by the processor by performinga read operation on the read_data register 814. an element of themicrocoded engine 106 writes the value 37 to the read_bits register 812.The element then performs a read on the read_data register 814.Responsive to receiving a read request via the read_data register 814,the variable length string interface 820 returns 37 bits from the readFIFO 822, starting with a bit at a “current read bit position” pointedto by a bit read pointer in the variable length string interface 820.The current read bit position is then incremented by 37. In exemplaryoperation of the present invention the “current read bit position” maybe advanced by 37 bits by writing the value 37 to the read_bitsregister.

Once a variable length code has been read from the stream buffer 108 viathe engine interface 207 and the BSB unit 206, the processor 220transfers the variable length code to the ILUT unit 214 (see FIG. 11).The ILUT unit 214 uses the variable length code to index lookup table412 to generate an index based on the variable length code and also usesthe escape code correlator 414 to determine a type of escape code. Basedon the type of escape code, the ILUT unit 214 may send a jump index tothe processor 220.

A variable length code that includes an escape code may be considered tohave two major parts: a code prefix; and a code value. The code valuemay be selected to represent a particular combination of run value andlevel value in the case of the delta-run escape code-type and thedelta-level escape code-type. Alternatively, the code value may beselected to precisely set out a run value and a level value in the caseof the full escape code-type. The code prefix includes a first portionto indicate an escape code and a second portion to indicate a particulartype of escape code.

The escape code correlator 414 receives the variable length code and anindication of the length of the first portion of the code prefix. Wherethe length of the first portion of the code prefix is N bits, acomparison unit 1202 (see FIG. 12) compares the first N bits of thereceived variable length code to the known escape code indication. Wherea match is found, the comparison unit 1202 generates an ESC_MATCH_FLAGsignal indicating the match. Where a match is not found, the comparisonunit 1202 does not generate a signal. The ESC_MATCH_FLAG signal may bereceived by an escape type extractor 1204.

The escape type extractor 1204 also receives the variable length codeand the indication of the length of the code prefix. Additionally, theescape type extractor 1204 may be preloaded with an indication of thelength of the second portion of the code prefix. Starting with the bitafter the final bit of the first portion of the code prefix, the escapetype extractor 1204 may record, responsive to receiving the trigger fromthe comparison unit 1202, the values of the bits indicative of theparticular type of escape code. Based on the recorded values, the escapetype extractor 1204 may generate an output string for transmission tothe processor 220.

In one instance of operation of the ILUT unit 214, if the type of codeis indicated as an explicit code, the index generated by the ILUT unit214 is transferred to the VLUT unit 212. The VLUT unit 212 finds a levelvalue and a run value in the value lookup table 702 (FIG. 13) based onthe received index. The level value and the run value are thentransferred to the CEB unit 208 according to instruction from theprocessor 220.

If the type of code is indicated as a delta-run escape code, the indexgenerated by the ILUT unit 214 is sent to the VLUT unit 212. The VLUTunit 212 finds a level value and a run value in a run and level lookuptable 704 (FIG. 13) based on the received index. Additionally, the levelvalue is sent to the ILUT unit 214 and the run value is sent to the ALU218. At the ILUT unit 214, a maximum run may be generated at the runmaxima lookup table 604 for the received level value. The processor maythen execute an instruction to transfer the maximum run to the ALU 218.At the ALU 218, the run value is added to the maximum run to generate anadjusted run value, which is received at the CEB unit 208 along with thelevel value determined by the VLUT unit 212.

If the type of code is indicated as a delta-level escape code, the indexgenerated by the ILUT unit 214 is sent to the VLUT unit 212. The VLUTunit 212 finds a level value and a run value in the run and level lookuptable 704 based on the received index. Additionally, the run value issent to the ILUT unit 214 and the level value is sent to the ALU 218. Atthe ILUT unit 214, a maximum level may be generated at the level maximalookup table 604 for the received run value. The processor may thenexecute an instruction to transfer the maximum level to the ALU 218. Atthe ALU 218, the level value is added to the maximum level to generatean adjusted level value, which is received at the CEB unit 208 alongwith the run value determined by the VLUT unit 212.

If the type of code is indicated as a full escape code, neither the VLUTunit 212 nor the ILUT unit 214 are used. The data following the fullescape code indication in the variable length code, i.e., the levelvalue and the run value, is routed directly to the CEB unit 208 by theprocessor 220.

Like the tables used in the encoding process, the tables used in thedecoding process (the variable length code to index lookup table 412,the escape code correlator 414, the run maxima lookup table 602, thelevel maxima lookup table 604, the run and level lookup table 704) canbe changed to support different compression methods and, consequently,different video encoding and decoding standards.

At the CEB unit 208, the decode mode involves the reception ofrun/level/last values, presented under control of the processor 220,which are subsequently loaded into the coefficient memory 306 to form ablock of DCT coefficients. The coefficients are then transferred, viathe DMA unit 302, from the coefficient memory 306 to the shared memory104. As mentioned previously, it is typical to treat the coefficientmemory 306 as a ping-pong buffer with each side holding one block ofcoefficients.

Once an initial block is written into the coefficient memory 306 by theprocessor 220, a second block may be written into the other side of thecoefficient memory 306 while the initial block is read by the DMA unit302 and written to the shared memory 104.

The sequence of events for decoding at the CEB unit 208 is illustratedin FIG. 15 to begin with the setting up of some registers in therun-level unit 308 (step 1502). In one register, a pointer to an addresswithin the coefficient memory 306 may be initialized (e.g., to a valueof “−1”). Another register may be established such that writing to thisregister triggers an initialization of the index register in the indexregister unit 310 for run/level processing. Additionally, a register maybe used to store an indication of the block size. Where the number ofcoefficients decoded is different from the indicated block size, it maybe considered that a bitstream error has occurred.

Registers may also be set up in the DMA unit 302 (step 1504). Twoidentical sets of registers may be set up to allow for separate andindependent access to the shared memory 104. The DMA registers mayinclude: a register for indicating a start address in the shared memory104; a register for indicating a start address in the coefficient memory306; a register for indicating a selection of a scan table in the scantable unit 304; and a register for indicating a number of 128-bit(eight-coefficient) words to transfer for each block.

The processor 220 may then trigger (step 1506) the various elements ofthe microcoded engine 106 to start decoding the contents to the streambuffer 108 as described above and write run/level values to the CEB unit208 until a block is complete.

FIG. 16 illustrates steps in an exemplary decoding method at the CEBunit 208. The run-level unit 308 may receive a first run value and afirst level value associated with the first run value (step 1602). Thefirst run value may be used to update the pointer (1604). In particular,the first run value may be added to the pointer, which is then furtherincremented by one. The first level value (WDATA) may then be stored inthe coefficient memory 306 at a memory location (WADDR) specified by theupdated pointer. As the run value may be considered to indicate a numberof zeroes that precede the associated level value, the level value isassumed to be non-zero. Corresponding to the storage of each receivedlevel value in the coefficient memory 306, a one-bit indication of thenon-zero nature of the level value (i.e., a NON_ZERO_FLAG) may be stored(step 1608) in the index register in the index register unit 310 at thememory location (WADDR) specified by the updated pointer.

Using the exemplary run and level values discussed above, the pointermay be initialized to “−1”. A first set of run and level data may bereceived as run=0, level=−474. As such, the pointer may be incrementedto 0 (pointer=pointer+run+1=−1+0+1) and the level value −474 may bestored in location 0 in the coefficient memory 306. Additionally, abinary 1 may be stored in location 0 in the index register in the indexregister unit 310. A second set of run and level data may be received asrun=0, level=−68. As such, the pointer may be incremented to 1 (0+0+1)and the level value −68 may be stored in location 1 in the coefficientmemory 306. Additionally, a binary 1 may be stored in location 1 in theindex register in the index register unit 310. A third set of run andlevel data may be received as run=2, level=−62. As such, the pointer maybe incremented to 4 (1+2+1) and the level value −62 may be stored inlocation 4 in the coefficient memory 306. Additionally, a binary 1 maybe stored in location 4 in the index register in the index register unit310. A fourth set of run and level data may be received as run=0,level=102. As such, the pointer may be incremented to 5 (4+0+1) and thelevel value 102 may be stored in location 5 in the coefficient memory306. Additionally, a binary 1 may be stored in location 5 in the indexregister in the index register unit 310. A fifth set of run and leveldata may be received as run=1, level=−71. As such, the pointer may beincremented to 7 (5+1+1) and the level value −71 may be stored inlocation 7 in the coefficient memory 306. Additionally, a binary 1 maybe stored in location 7 in the index register in the index register unit310. The updating of the pointer and the storing of coefficient valuesin the coefficient memory 306 and storing the NON_ZERO_FLAG in the indexregister in the index register unit 310 continues until the block iscomplete.

Advantageously, at the beginning of the populating of the coefficientmemory 306, the index register in the index register unit 310 is filledwith zeros. At the end of the populating of the coefficient memory 306,the index register in the index register unit 310 only has values of oneat locations corresponding to the memory locations in the coefficientmemory 306 at which level values have been stored. As such, there is noneed to perform initialization of the coefficient memory 306, which ismuch larger than the index register and, therefore, takes longer toinitialize. Thus, a time savings is realized through the use of thismethod.

The processor 220 may repeatedly trigger the decoding, by the run-levelunit 308, of run and level information determined, by the combination ofthe ILUT unit 214 and the VLUT unit 212, from a variable length codereceived from the stream buffer 108 (step 1506) until the processor 220determines (step 1508) that an entire block has been written to thecoefficient memory 306, e.g., by recognizing a last indication inreceived run/level/last information.

Once it has been determined (step 1508) that an entire block has beenwritten to the coefficient memory 306, the processor 220 may make adetermination as to whether a previously triggered DMA operation hascompleted (step 1510). To make such a determination, the processor 220may read the DMA status register. Upon determining that a previouslytriggered DMA operation has completed (step 1510), the processor 220 maytrigger (step 1512) the DMA unit 302 to read the coefficient memory 306and write to the shared memory 104, first, by writing an indication toone of the two DMA setup registers to be used for such a purpose and,second, by writing an indication that the required operation is a DMAWrite (put) operation.

The transfer of the blocks of DCT coefficients from the coefficientmemory 306 into the shared memory 104 may be arranged to occur onecoefficient at a time. Alternatively groups of coefficients may beaggregated to permit larger transfers to the shared memory 104. The DMAunit 302 specifies the memory location (ADDR, see FIG. 14) of a specificcoefficient to the scan table unit 304, where the memory location (ADDR)of the specific coefficient relates to a memory location in thecoefficient array as it will be stored in the shared memory 104. Thescan table unit 304 may use a selected RAM-based scan table to determinea read memory location (RADDR) for the specific coefficient in thecoefficient array as stored in the coefficient memory 306.

The same read memory location (RADDR) is transmitted to (that is, placedon an address bus available to) the index register unit 310 to trigger aresponse indicating the present or absence of a coefficient in thespecified memory location in the coefficient memory 306. Once the DMAunit 302 receives the specific coefficient (RDATA) and the response(NON_ZERO_FLAG) from the index register unit 310, the DMA unit 302 mayconsider the response from the index register unit 310.

If the response from the index register unit 310 indicates that acoefficient is present at the specified memory location, the DMA unit302 may transmit the specific coefficient (WDATA) to the shared memory104. If the response from the index register unit 310 indicates that acoefficient is absent at the specified memory location, the DMA unit 302may transmit a null value (WDATA) to the shared memory 104.

At this point the processor 220 may, again, set up the registers (step1502) in the run-level unit 308 for receiving the next block of DCTcoefficients.

Once the processor 220 has determined that the requested memory accessis complete, the transfer of the block from the stream buffer 108 to theshared memory 104 may considered complete. However, it should be notedthat, even as the CEB unit 208 completes transferring one block from oneside of the coefficient memory 306 to the shared memory 104, the nextblock is being loaded into the other side of the coefficient memory 306.

Once a block of DCT coefficients has been transferred to the sharedmemory 104, the block of DCT coefficients in the shared memory 104 maythen be read by the DCT unit 102 (see FIG. 1) and converted, by the DCTunit 102, to a digital video sequence.

Other modifications will be apparent to those skilled in the art.

1. An escape code selection apparatus for producing variable lengthcoded data, said escape code selection apparatus comprising: a firstcomparator adapted to compare a received run value to a previouslystored run value to produce a first comparison result; a secondcomparator adapted to compare a received level value to a previouslystored level value to produce a second comparison result; and a logicunit adapted to select, based, at least in part, on said firstcomparison result and said second comparison result, an escape code,including an escape code type from among a plurality of escape codetypes; said escape code type reflecting one of a predefined set ofarithmetic relationships between said received run value and saidreceived level value, and an entry within a codebook.
 2. The escape codeselection apparatus of claim 1 wherein said logic unit is furtheradapted to: select an index to an instruction based on said escape codetype; and transmit said index to a processor.
 3. The escape codeselection apparatus of claim 1, wherein said escape code types identifya delta run value escape code, or a delta level value escape code. 4.The escape code selection apparatus of claim 1, wherein said logic unitis adapted to create an escape code including a codebook entrycorresponding to said received level value and a run value equal to adifference between said received run value and said previously storedrun value.
 5. The escape code selection apparatus of claim 1, whereinsaid logic unit is adapted to create an escape code including a codebookentry corresponding to said received run value and a level value equalto a difference between said received level value and said previouslystored level value.
 6. The escape code selection apparatus of claim 5,wherein said previously stored run level is the largest run value for agiven level value in said codebook.
 7. The escape code selectionapparatus of claim 4, wherein said previously stored run level is thelargest run value for a given level value in said codebook.
 8. A methodcomprising: receiving a run value and level value combination;determining that said run value and level value combination to beencoded is not represented within a codebook; determining one of aplurality of defined arithmetic relationships between said run value andlevel value combination and an entry in said codebook; forming an escapecode based on said determined one of said plurality of arithmeticrelationships, and including in said escape code an indicator of saiddetermined arithmetic relationship.
 9. The method of claim 8, whereinsaid entry of said codebook has the run value of said run value andlevel value combination and said one of said defined arithmeticrelationships includes a difference between the level value of the runvalue and level value combination, and the level value of said entry insaid codebook.
 10. The method of claim 9, wherein said entry in saidcodebook has the largest level value for a given run value in saidcodebook.
 11. The method of claim 10, wherein said escape code includesa codebook entry corresponding to said run value of said run value andlevel value combination, and a level value equal to a difference betweenthe level value of said run value and level value combination, and thelevel value of said entry in said codebook.
 12. The method of claim 8,wherein said entry of said codebook has the level value of said runvalue and level value combination and said one of said definedarithmetic relationships includes a difference between the run value ofthe run value and level value combination, and the run value of saidentry in said codebook.
 13. The method of claim 12, wherein said entryin said codebook has the largest level value for a given run value insaid codebook.
 14. The method of claim 13, wherein said escape codeincludes a codebook entry corresponding to said level value of said runvalue and level value combination, and a run value equal to a differencebetween the run value of said run value and level value combination, andthe run value of said entry in said codebook.
 15. The method of claim 8,wherein said forming comprises forming an escape code including said runvalue and said level value combination, for run values or level valuesin said run value and level combination, in excess of defined maxima.